package com.stu.domain;

import java.util.List;

public class Page {
	private List records;
	private int pagesize = 10;
	private int pagenum;
	private int totalpage;
	private int startIndex;
	private int totalrecords;
	private int startpage;
	private int endpage;
	private String servleturl;
	public Page(int pagenum, int totalrecords) {
		this.pagenum = pagenum;
		this.totalrecords = totalrecords;
		this.startIndex = (pagenum - 1) * pagesize;
		this.totalpage = (totalrecords % pagesize == 0) ? (totalrecords / pagesize)
				: (totalrecords / pagesize + 1);
		if (totalpage<=9) {
			startpage=1;
			endpage=totalpage;
		}else{
			startpage=pagenum-4;
			endpage=pagenum+4;
			if (startpage<1) {
				startpage=1;
				endpage=9;
			} 
			if(endpage>totalpage) {
				endpage=totalpage;
				startpage=totalpage-9;
			}
		}
	}

	public List getRecords() {
		return records;
	}

	public void setRecords(List records) {
		this.records = records;
	}

	public int getPagesize() {
		return pagesize;
	}

	public void setPagesize(int pagesize) {
		this.pagesize = pagesize;
	}

	public int getPagenum() {
		return pagenum;
	}

	public void setPagenum(int pagenum) {
		this.pagenum = pagenum;
	}

	public int getTotalpage() {
		return totalpage;
	}

	public void setTotalpage(int totalpage) {
		this.totalpage = totalpage;
	}

	public int getStartIndex() {
		return startIndex;
	}

	public void setStartIndex(int startIndex) {
		this.startIndex = startIndex;
	}

	public int getTotalrecords() {
		return totalrecords;
	}

	public void setTotalrecords(int totalrecords) {
		this.totalrecords = totalrecords;
	}

	public int getStartpage() {
		return startpage;
	}

	public void setStartpage(int startpage) {
		this.startpage = startpage;
	}

	public int getEndpage() {
		return endpage;
	}

	public void setEndpage(int endpage) {
		this.endpage = endpage;
	}

	public String getServleturl() {
		return servleturl;
	}

	public void setServleturl(String servleturl) {
		this.servleturl = servleturl;
	}

}
